﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pool
{
    class ResourcePool
    {
        private List<Resource> resources;

        public ResourcePool()
        {
            resources=new List<Resource>();
        }

        public void Add(Resource resource)
        {
            if (resource.Available == true)
            {
                resources.Add(resource);
                resource.Available = false;
            }
            else
            {
                Console.WriteLine("The resource is not available!");
            }
        }
        public void Remove(Resource resource)
        {
            if (resources.Count == 0)
            {
                Console.WriteLine("The resource doesn't exist in tne pool!");
            }
            foreach (var res in resources)
            {
                if (res == resource)
                {
                    resources.Remove(resource);
                    resource.Dispose();
                    break;
                }
                Console.WriteLine("The resource doesn't exist in tne pool!");
            }

            
        }
    }
}
